package com.code.leetcode.offer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/8/4 13:37
 */
public class The57_2_双指针 {
    public int[][] findContinuousSequence(int target) {
        int left = 1, right = 1;
        int sum = 0;
        List<int[]> lists = new ArrayList<>();

        while (left < target / 2) {
            if (sum < target) {
                sum += right;
                right++;
            } else if (sum > target) {
                sum -= left;
                left++;
            } else {
                int[] ints = new int[right - left];
                for (int i = left; i < right; i++) {
                    ints[i - left] = i;
                }
                lists.add(ints);
                sum -= left;
                left++;
            }
        }
        return lists.toArray(new int[lists.size()][]);
    }
}
